
'use strict';

const ueditor = require('koa2-ueditor');
const path = require('path');
/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const subRouter = app.router.namespace('/admin');
  // curl localhost:7001/sub/test
  subRouter.get('/', app.controller.admin.index);
  subRouter.get('/login', app.controller.admin.login);
  subRouter.get('/loginAction', app.controller.admin.loginAction);
  subRouter.get('/banner', app.controller.admin.banner);
  subRouter.post('/delBanner', app.controller.admin.delBanner);
  subRouter.post('/banner/add', app.controller.admin.bannerAdd);
  subRouter.get('/consult', app.controller.admin.consult);
  subRouter.get('/consult/:id', app.controller.admin.consultDetail);
  subRouter.get('/project', app.controller.admin.project);
  subRouter.get('/project/:id', app.controller.admin.projectDetail);
  subRouter.get('/notification', app.controller.admin.notification);
  subRouter.post('/uploadArticle', app.controller.admin.uploadArticle);
  subRouter.post('/updateArticle', app.controller.admin.updateArticle);
  subRouter.post('/updateProject', app.controller.admin.updateProject);
  subRouter.post('/updateHistory', app.controller.admin.updateHistory);
  subRouter.post('/delArticle', app.controller.admin.delArticle);
  subRouter.post('/uploadProject', app.controller.admin.uploadProject);
  subRouter.post('/uploadNotification', app.controller.admin.uploadNotification);
  subRouter.all('/editor', ueditor(path.join(__dirname, '../public/')));
  // subRouter.get('sub_upload', '/upload', app.controller.sub.upload);

  // const subRouter = app.router.namespace('/sub/:id');
  // cont subRouter = app.router.namespace('/sub', app.middleware.jsonp());

  // output: /sub/upload
};
